Replace guava caches with caffeine Replacing Guava caches with Caffeine reduces the chances of having the deadlocks and improves the cache performance. This was already attempted in: I8d2b17a94d0, but got reverted in: If65560b4a9b due to recursion in PatchListLoader. This recursion issue is present on current master. While this change replaces all caches with Caffeine backend, the follow-up change in this series will switch back to using Guava backend for PatchListCache implementation. For seamless integration, the caffeine-guava adapter library is used. Given that the final artifact for the adapter is also called guava, there is only the version number that differentiates that artifact from the guava library itself so that we have a danger for naming collision. To avoid potential naming collision risk, rename the library name to caffeine-guava.jar during the fetch from Maven Central. Alternatives considered is not to use the caffeine-guava adapter library. But then the Cache and LoadingCache classes and friends would change the package name from com.google.common.cache package to com.github.benmanes.caffeine.cache package and this change would also affect some gerrit plugins and thus considered to be a quite intrusive change. Still we can consider to do this change in one of the future gerrit releases. Bug: Issue 7645 Bug: Issue 11484 Change-Id: I6af4c15d6c15f438becd62409b7d233c309be8de
diff --git a/WORKSPACE b/WORKSPACE index 4e2c970..7529d8a 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -241,6 +241,31 @@ sha1 = "1dcf1de382a0bf95a3d8b0849546c88bac1292c9", ) +CAFFEINE_VERS = "2.8.0" + +maven_jar( + name = "caffeine", + artifact = "com.github.ben-manes.caffeine:caffeine:" + CAFFEINE_VERS, + sha1 = "6000774d7f8412ced005a704188ced78beeed2bb", +) + +# TODO(davido): Rename guava.jar to caffeine-guava.jar on fetch to prevent potential +# naming collision between caffeine guava adapater and guava library itself. +# Remove this renaming procedure, once this upstream issue is fixed: +# https://github.com/ben-manes/caffeine/issues/364. +http_file( + name = "caffeine-guava-renamed", + downloaded_file_path = "caffeine-guava-" + CAFFEINE_VERS + ".jar", + sha256 = "3a66ee3ec70971dee0bae6e56bda7b8742bc4bedd7489161bfbbaaf7137d89e1", + urls = [ + "https://repo1.maven.org/maven2/com/github/ben-manes/caffeine/guava/" + + CAFFEINE_VERS + + "/guava-" + + CAFFEINE_VERS + + ".jar", + ], +) + maven_jar( name = "jsch", artifact = "com.jcraft:jsch:0.1.54",